package com.stormrage.edu.dao.exam.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.exam.ExmTermScoreDao;
import com.stormrage.entity.exam.ExmTermScore;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @Title: ExmTermScoreDaoImpl.java
 * @Package com.stormrage.edu.dao.exam.impl
 * @Description: 学期题目成绩 Dao
 * @author www.stormragetech.com
 * @date 2016年5月14日
 * @version V1.0
 */
@Repository
public class ExmTermScoreDaoImpl extends MysBaseDao implements ExmTermScoreDao {

	private static final Logger logger = LoggerFactory.getLogger(ExmTermScoreDaoImpl.class);

	@Override
	public Integer create(final ExmTermScore arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 Create 】-【 STARTED 】");

		final String query = "INSERT INTO exm_term_score (term_id, sele, mult, corr) VALUES"
				+ " (:termId, :sele, :mult, :corr)";
		logger.debug(" 数据库执行语句为 " + query);

		Integer index = create(query, arg0);

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 Create 】-【 COMPLETED 】");
		return index;

	}

	@Override
	public void update(final ExmTermScore arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 update 】-【 STARTED 】");

		final String query = "UPDATE exm_term_score SET sele = :sele, mult = :mult, corr = :corr WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		update(query, arg0);

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 update 】-【 COMPLETED 】");

	}

	@Override
	public ExmTermScore queryById(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 queryById 】-【 STARTED 】");

		final String query = "SELECT * FROM exm_term_score WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		ExmTermScore entity = queryObject(query, ExmTermScore.class, map);

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 queryById 】-【 COMPLETED 】");
		return entity;

	}

	@Override
	public ExmTermScore queryByTermId(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 queryByTermId 】-【 STARTED 】");

		final String query = "SELECT * FROM exm_term_score WHERE term_id = :termId";
		logger.debug(" 数据库执行语句为 " + query);

		ExmTermScore entity = queryObject(query, ExmTermScore.class, map);

		logger.debug(" 【 Dao 】-【 ExmTermScoreDao 】-【 queryByTermId 】-【 COMPLETED 】");
		return entity;

	}

}
